import Toast from 'react-native-toast-message';

const showToast = ({
  type = 'info',
  text1 = '',
  text2 = 'This is a toast message!',
  position = 'bottom',
  visibilityTime = 2000,
  fontSize = 16,
} = {}) => {
  return new Promise(resolve => {
    const toast = Toast.show({
      type,
      text1,
      text2,
      position,
      visibilityTime,
      text2Style: {fontSize},
    });
    setTimeout(() => {
      Toast.hide(toast);
      resolve(); // 提示框隐藏后 resolve Promise
    }, visibilityTime);
  });
};

export {showToast};
